﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ScrumBoard
{
  public static class Extensions
  {
    public static T VisualParent<T>(this FrameworkElement element) where T : FrameworkElement
    {
      while (element.Parent is FrameworkElement)
      {
        element = (FrameworkElement)element.Parent;
        if (element is T) return (T)element;
      }
      return null;
    }

    public static FrameworkElement VisualParent(this FrameworkElement element)
    {
      return VisualTreeHelper.GetParent(element) as FrameworkElement;
    }
  }
}
